package com.pro.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;

public class PropertiesUtil {
	private static String file_path = "generator.properties";
	public static Properties loadProperties(String path) throws FileNotFoundException, IOException{
		Properties properties = new Properties();
		URL url = PropertiesUtil.class.getClassLoader().getResource("");
		System.out.println(url.getPath());
		File file = new File(url.getPath()+"generator.properties");
		InputStream in =null;
		if(file.exists()){
			in = new FileInputStream(file);
		}else{
			in = PropertiesUtil.class.getClassLoader().getResourceAsStream(file_path);
		}
		properties.load(in);
		return properties;
	}
	/*public static void main(String[] args) {
		URL url = PropertiesUtil.class.getClassLoader().getResource("generator.properties1");
		System.out.println(url);
	}*/
}
